EnableExplicit
XIncludeFile "layout.pbi"

; Test template

;{-- purevd start
Declare btnOk_Click()
Declare btnCancel_Click()

Procedure InitialiseGadgets()
  Protected rv.i, WinID.i, tmpID.i
  NewList Contain.i()
  
  ; AddGadget(pName.s, pParentID.i, pGadgetType.i, pText.s, pDesiredWidth.i, pDesiredHeight.i, pFlexWidthType.b, pFlexHeightType.b, pFlags.i = 0, pPath.s = "")
  
  ; add the window
  AddElement(Contain())
  Contain() = AddGadget("winMain", -1, -1, #PB_GadgetType_Window, "Main Window", 600, 400, 0, 0, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
  WinID = Contain()
  
  ; All controls to be added here is in a verticle arrangement (vbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Container_frmShowOff", tmpID, WinID, #PB_GadgetType_VBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a frame
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("frmShowOff", tmpID, WinID, #PB_GadgetType_Frame3D, "Showing Off", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; All controls to be added here is in a verticle arrangement (vbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_vbox_frmShowOff", tmpID, WinID, #PB_GadgetType_VBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; All controls to be added here is in a horizontal arrangement (hbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_hbox1_frmShowOff", tmpID, WinID, #PB_GadgetType_HBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a text gadget set to minimum size
  AddGadget("txtShowOff1", Contain(), WinID, #PB_GadgetType_Text, "Name", #PB_Any, #PB_Any, #Sizing_MinimumSize, #Sizing_Centre)
  ; add a string gadget set to fill the rest of the frame
  AddGadget("strShowOff1", Contain(), WinID, #PB_GadgetType_String, "<Name goes here>", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Centre)
  
  DeleteElement(Contain()) ; back up to frame
  
  ; add another set of controls in a horizontal arrangement (hbox)
  tmpID = Contain()
  AddElement(Contain())
  Contain() = AddGadget("Items_hbox2_frmShowOff", tmpID, WinID, #PB_GadgetType_HBox, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  ; add a text gadget set to minimum size
  AddGadget("txtShowOff2", Contain(), WinID, #PB_GadgetType_Text, "E-mail", #PB_Any, #PB_Any, #Sizing_MinimumSize, #Sizing_Centre)
  ; add a string gadget set to fill the rest of the frame
  AddGadget("strShowOff2", Contain(), WinID, #PB_GadgetType_String, "<Password goes here>", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Centre)
  
  
   DeleteElement(Contain()) ; back up to frame vbox
   DeleteElement(Contain()) ; back up to frame
   DeleteElement(Contain()) ; back up to window vbox
  
  AddGadget("spacer1", Contain(), WinID, #PB_GadgetType_Spacer, "", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
  
  AddGadget("btnOk", Contain(), WinID, #PB_GadgetType_Button, "OK", 100, 100, #Sizing_Fixed, #Sizing_Fixed)
  AddGadget("btnCancel", Contain(), WinID, #PB_GadgetType_Button, "Cancel", #PB_Any, #PB_Any, #Sizing_Stretch, #Sizing_Stretch)
EndProcedure

Procedure GadgetEventSelection(pWindowEvent, pGadgetEvent, pTypeEvent)
  ForEach gl()
    If pWindowEvent = gl()\WindowID And gl()\ID = pGadgetEvent
      Break
    EndIf
  Next
  
  Select gl()\Name
    Case "btnOk"
      If pTypeEvent = #PB_EventType_LeftClick
        btnOK_Click()
      EndIf
    Case "btnCancel"
      If pTypeEvent = #PB_EventType_LeftClick
        btnCancel_Click()
      EndIf
  EndSelect
  
EndProcedure

Procedure MenuEventSelection(pWindowEvent, pMenuEvent)
  ForEach gl()
    If pWindowEvent = gl()\WindowID And gl()\ID = pMenuEvent
      Break
    EndIf
  Next
  
  Select gl()\Name
  EndSelect
EndProcedure

;}-- purevd end

Procedure btnOk_Click()
  MessageRequester("Main", "Name:" + GetGadgetText(GetGadgetID("winMain", "strShowOff1")) + Chr(13)+Chr(10) + "Email:" + GetGadgetText(GetGadgetID("winMain", "strShowOff2")))
EndProcedure

Procedure btnCancel_Click()
  MessageRequester("Main", "Cancel")
EndProcedure

InitialiseGadgets()
EventLoop()

End

; IDE Options = PureBasic 4.60 Beta 3 (Windows - x86)
; CursorPosition = 112
; FirstLine = 69
; Folding = --
; EnableXP